from web_core import GetCore
from urllib2 import Request
from settings import headers
import os
class Baidu():
	BaseUrl = "http://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&rsv_idx=1&tn=baidu&wd={}&rsv_pq=aa862ab800006438&rsv_t=fd75YcjTG1I8VGu29D2p4tpUiniCNz0mCQifo5VzY7lUS9C9ryOuJ5ZhkEw&rsv_enter=1&inputT=3395&rsv_sug1=15&rsv_sug3=13&rsv_sug4=376&rsv_sug2=0"
	def __init__(self,*keys):
		self.headers = headers
		self.headers['Host'] = 'www.baidu.com'
		keys = "%20".join(keys)
		self.url = Baidu.BaseUrl.format(keys)
		self.request = GetCore.get([self.url,self.headers])

	@classmethod
	def get(cls,*key):
		c = cls(*key)
		respond = GetCore.read_http(c.request)
		return respond

